package com.tiyo.system.service.impl;

import java.util.Arrays;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tiyo.system.mapper.SysUserMapper;
import com.tiyo.system.mapper.SysUserRoleMapper;
import com.tiyo.system.mapper.domain.SysUser;
import com.tiyo.system.mapper.domain.SysUserRole;
import com.tiyo.system.service.SysUserService;
@Service
public class SysUserServiceImpl implements SysUserService {
	@Autowired
	SysUserMapper sysUserMapper;
	@Autowired
	SysUserRoleMapper sysUserRoleMapper;
	@Override
	public List<SysUser> selectUserList(SysUser user) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<SysUser> selectAllocatedList(SysUser user) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<SysUser> selectUnallocatedList(SysUser user) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public SysUser selectUserByLoginName(String userName) {
		QueryWrapper<SysUser> queryWrapper = new QueryWrapper<SysUser>();
		queryWrapper.eq("login_name", userName);
		return sysUserMapper.selectOne(queryWrapper);
	}

	@Override
	public SysUser selectUserByPhoneNumber(String phoneNumber) {
		QueryWrapper<SysUser> queryWrapper = new QueryWrapper<SysUser>();
		queryWrapper.eq("tel", phoneNumber);
		return sysUserMapper.selectOne(queryWrapper);
	}

	@Override
	public SysUser selectUserByEmail(String email) {
		QueryWrapper<SysUser> queryWrapper = new QueryWrapper<SysUser>();
		queryWrapper.eq("email", email);
		return sysUserMapper.selectOne(queryWrapper);
	}

	@Override
	public SysUser selectUserById(String userId) {
		return sysUserMapper.selectById(userId);
	}

	@Override
	public List<SysUserRole> selectUserRoleByUserId(String userId) {
		QueryWrapper<SysUserRole> queryWrapper = new QueryWrapper<SysUserRole>();
		queryWrapper.eq("user_Id", userId);
		return sysUserRoleMapper.selectList(queryWrapper);
	}

	@Override
	public int deleteUserById(String userId) {
		return sysUserMapper.deleteById(userId);
	}

	@Override
	public int deleteUserByIds(String ids) throws Exception {
		return sysUserMapper.deleteBatchIds(Arrays.asList(ids.split(",")));
	}

	@Override
	public int insertUser(SysUser user) {
		return sysUserMapper.insert(user);
	}

	@Override
	public boolean registerUser(SysUser user) {
		return false;
	}

	@Override
	public int updateUser(SysUser user) {
		return 0;
	}

	@Override
	public int updateUserInfo(SysUser user) {
		return sysUserMapper.updateById(user);
	}

	@Override
	public void insertUserAuth(Long userId, Long[] roleIds) {
		// TODO Auto-generated method stub

	}

	@Override
	public int resetUserPwd(SysUser user) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public String checkLoginNameUnique(String loginName) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String checkPhoneUnique(SysUser user) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String checkEmailUnique(SysUser user) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void checkUserAllowed(SysUser user) {
		// TODO Auto-generated method stub

	}

	@Override
	public String selectUserRoleGroup(Long userId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String selectUserPostGroup(Long userId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int changeStatus(SysUser user) {
		// TODO Auto-generated method stub
		return 0;
	}

}
